from pyautogui import center,click,locateOnScreen,hotkey
from time import sleep
import configparser
import subprocess
import os
def main():

    if not os.path.exists('config.ini'):
        open('config.ini','w').write('[path]\nwemeetapp =')

    config = configparser.ConfigParser()
    config.read("config.ini")
    if len(config.get('path','wemeetapp')) == 0:
        config.set('path','wemeetapp',input("drag wemeetapp.exe："))
        config.write(open("config.ini",'w'))
        subprocess.Popen(config.get('path', 'wemeetapp'))
        sleep(5)

    else:
        subprocess.Popen(config.get('path','wemeetapp'))

    print("hooking")

    def bypass(b):
        sleep(0.5)
        click(center(b))

    def bypass2(bb):
        sleep(0.5)
        click(center(bb))
        print('Bypassed Successfully')
        hotkey('alt','f4')
        
    def error1(bbb):
        sleep(0.5)
        click(center(bbb))
        print('Troubleshooted Successfully')

		
    while True:
        a = locateOnScreen('sign.png',confidence=0.9)
        if a:
            bypass(a)

        aa = locateOnScreen('sign2.png',confidence=0.9)
        if aa:
            bypass2(aa)
            sleep(10)
        
        aaa = locateOnScreen('sign3.png',confidence=0.9)
        if aaa:
            error1(aaa)


if __name__ == '__main__':
    main()
